Learn R Programming

distr6 (version 1.4.8)

[.ParameterSet: Extract one or more parameters from a ParameterSet

Description

Used to extract one or more parameters from a constructed ParameterSet or ParameterSetCollection.

Usage

# S3 method for ParameterSet
[(ps, ids, prefix = NULL, ...)

Arguments

ps

ParameterSet ParameterSet from which to extract parameters.

ids

(character()) ids of parameters to extract, if id ends with _ then all parameters starting with ids_ are extracted and the prefix is ignored, prefix can be left NULL. See examples.

prefix

(character(1)) An optional prefix to remove from ids after extraction, assumes _ follows the prefix name, i.e. prefix_ids.

...

ANY Ignored, added for consistency.

Examples

Run this code
# NOT RUN {
ps <- VectorDistribution$new(
  distribution = "Binomial",
  params = data.table::data.table(prob = c(0.1, 0.6, 0.2), size = c(2, 4, 6))
)$parameters()

ps["Binom1_prob"] # extracts just Binom1_prob
ps["Binom1_prob", prefix = "Binom1"] # extracts Binom1_prob and removes prefix
ps["Binom1_"] # extracts all Binom1 parameters and removes prefix
# }

Run the code above in your browser using DataLab